You are here: Symbol Reference > Dew Namespace > Dew.Math Namespace > Dew.Math.Units Namespace > Classes > Optimization Class > Optimization Methods > Simplex Method > Optimization.Simplex Method (TRealFunction, double[], [In] double[], [In] object[], out double, out TOptStopReason, [In] TMtxFloatPrecision, int, double, [In] TStrings)
Dew Math for .NET
ContentsIndexHome
PreviousUpNext
Optimization.Simplex Method (TRealFunction, double[], [In] double[], [In] object[], out double, out TOptStopReason, [In] TMtxFloatPrecision, int, double, [In] TStrings)

Minimizes the function of several variables by using the Nelder-Mead (Simplex) optimization method.

Syntax
C#
Visual Basic
public static int Simplex(TRealFunction Func, ref double[] Pars, [In] double[] Consts, [In] object[] ObjConst, out double FMin, out TOptStopReason StopReason, [In] TMtxFloatPrecision FloatPrecision, int MaxIter, double Tolerance, [In] TStrings Verbose);
Parameters 
Description 
TRealFunction Func 
Real function (must be of TRealFunction type) to be minimized. 
ref double[] Pars 
Stores the initial estimates for parameters (minimum estimate). After the call to routine returns adjusted calculated values (minimum position). 
[In] double[] Consts 
Additional Fun constant parameteres (can be/is usually nil). 
[In] object[] ObjConst 
Additional Fun constant parameteres (can be/is usually nil). 
out double FMin 
Returns function value at minimum. 
out TOptStopReason StopReason 
Returns reason why minimum search stopped (see TOptStopReason). 
[In] TMtxFloatPrecision FloatPrecision 
Specifies the floating point precision to be used by the routine. 
int MaxIter 
Maximum allowed numer of minimum search iterations. 
double Tolerance 
Desired Pars - minimum position tolerance. 
[In] TStrings Verbose 
If assigned, stores Fun, evaluated at each iteration step. Optionally, you can also pass TOptControl object to the Verbose parameter. This allows the optimization procedure to be interrupted from another thread and optionally also allows logging and iteration count monitoring.  

the number of iterations required to reach the solution(minimum) within given tolerance.

Minimizes the function of several variables by using the Nelder-Mead (Simplex) optimization method. The advantage of Simplex method is it does not require gradient or Hessian.

Problem: Find the minimum of the "Banana" function by using the Nelder-Mead (Simplex) method. 

Solution:The Banana function is defined by the following equation: 

 

 

private double Banana(TVec x, TVec c, params object[] o) { return 100*Math387.IntPower(x[1] - Math387.IntPower(x[0],2),2) + Math387.IntPower(1 - x[0],2); } private void Example() { double[2] x; double fmin; TOptStopReason StopReason; // initial estimates for x1 and x2 x[0] = 0; x[1] = 0; int iters = Simplex(Banana,x,null,null,out fmin,out StopReason, TMtxFloatPrecision.mvDouble, 1000,1.0E-8,null); // stop if Iters >1000 or Tolerance < 1e-8 // Returns x = [1,1] and FMin = 0, meaning x1=1, x2=1 and minimum value is 0 }
Copyright (c) 1999-2024 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!